
package com.idealighter.game.games.happyfive.handler;

import com.idealighter.game.core.annotation.ResMsgHandler;
import com.idealighter.game.gamehall.dto.MemInfo;
import com.idealighter.game.gamehall.dto.SeatInfo;
import com.idealighter.game.games.happyfive.HappyFivePlayer;
import com.idealighter.game.games.happyfive.message.ResChipsChangeMsg;
import com.idealighter.game.message.core.ResMessage;
import com.idealighter.game.robot.core.Player;
import com.idealighter.game.robot.handler.ResMessageHandler;


@ResMsgHandler(507221)
public class ResChipsChangeHandler implements ResMessageHandler {

  // private static final Logger LOG = LoggerFactory.getLogger(ResChipsChangeHandler.class);

  @Override
  public void action(Player player, ResMessage message) {
    ResChipsChangeMsg msg = (ResChipsChangeMsg) message;
    HappyFivePlayer happyFivePlayer = (HappyFivePlayer) player;
    SeatInfo seat = happyFivePlayer.seat(player.playerId);
    if (seat.getOrder() == msg.getOrder()) {
      MemInfo memInfo = happyFivePlayer.member(player.playerId);
      memInfo.setChips(msg.getChips());
    }
  }
}
